/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ArtistaCadastro.java
 *
 * Created on 28/10/2011, 16:06:46
 */
package br.com.beethoven.ui;

import br.com.beethoven.exception.BDException;
import br.com.beethoven.model.entidade.vo.BandaVO;
import br.com.beethoven.model.fachada.IGerenciarBandaFacade;
import br.com.beethoven.model.fachada.impl.GerenciarBandaFacade;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

/**
 *
 * @author gustavoalves
 */
public class ArtistaCadastro extends javax.swing.JFrame {
    private IGerenciarBandaFacade iGerenciarBanda;
    private BandaVO bandaVO;
    
    /** Creates new form ArtistaCadastro */
    public ArtistaCadastro() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        artistaNomeField = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        artistaDescricaoField = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        artistaMenu = new javax.swing.JMenu();
        artistaCadastrarMenu = new javax.swing.JMenuItem();
        artistaListarMenu = new javax.swing.JMenuItem();
        albumMenu = new javax.swing.JMenu();
        albumCadastrarMenu = new javax.swing.JMenuItem();
        albumListarMenu = new javax.swing.JMenuItem();
        musicaMenu = new javax.swing.JMenu();
        musicaCadastrarMenu = new javax.swing.JMenuItem();
        musicaListarMenu = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Nome");

        jLabel2.setText("Descrição");

        artistaNomeField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                artistaNomeFieldActionPerformed(evt);
            }
        });

        artistaDescricaoField.setColumns(20);
        artistaDescricaoField.setRows(5);
        jScrollPane1.setViewportView(artistaDescricaoField);

        jButton1.setText("Cadastrar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        artistaMenu.setText("Artista");

        artistaCadastrarMenu.setText("Cadastrar");
        artistaCadastrarMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                artistaCadastrarMenuActionPerformed(evt);
            }
        });
        artistaMenu.add(artistaCadastrarMenu);

        artistaListarMenu.setText("Listar");
        artistaListarMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                artistaListarMenuActionPerformed(evt);
            }
        });
        artistaMenu.add(artistaListarMenu);

        jMenuBar1.add(artistaMenu);

        albumMenu.setText("Álbum");

        albumCadastrarMenu.setText("Cadastrar");
        albumCadastrarMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                albumCadastrarMenuActionPerformed(evt);
            }
        });
        albumMenu.add(albumCadastrarMenu);

        albumListarMenu.setText("Listar");
        albumListarMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                albumListarMenuActionPerformed(evt);
            }
        });
        albumMenu.add(albumListarMenu);

        jMenuBar1.add(albumMenu);

        musicaMenu.setText("Música");

        musicaCadastrarMenu.setText("Cadastrar");
        musicaCadastrarMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                musicaCadastrarMenuActionPerformed(evt);
            }
        });
        musicaMenu.add(musicaCadastrarMenu);

        musicaListarMenu.setText("Listar");
        musicaListarMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                musicaListarMenuActionPerformed(evt);
            }
        });
        musicaMenu.add(musicaListarMenu);

        jMenuBar1.add(musicaMenu);

        setJMenuBar(jMenuBar1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(34, 34, 34)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jButton1)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel1)
                    .add(jLabel2)
                    .add(artistaNomeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 245, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(223, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(6, 6, 6)
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(artistaNomeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(jButton1)
                .addContainerGap(80, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void artistaNomeFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_artistaNomeFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_artistaNomeFieldActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
    iGerenciarBanda = new GerenciarBandaFacade();
    bandaVO = new BandaVO();
    
    bandaVO.setNome(artistaNomeField.getText());
    bandaVO.setDescricao(artistaDescricaoField.getText());
        try {
            iGerenciarBanda.cadastrar(bandaVO);
            JOptionPane.showMessageDialog(this, "Cadastro efetuado com Sucesso!");
            ArtistaCadastro artistaCadastro = new ArtistaCadastro();
            artistaCadastro.setVisible(true);
            this.dispose();
        } catch (BDException ex) {
            JOptionPane.showMessageDialog(this, "Erro ao cadastrar!");
            System.out.println("Erro");
        }
}//GEN-LAST:event_jButton1ActionPerformed

private void artistaCadastrarMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_artistaCadastrarMenuActionPerformed
// TODO add your handling code here:
    ArtistaCadastro artista = new ArtistaCadastro();
    artista.setVisible(true);
    this.dispose();
}//GEN-LAST:event_artistaCadastrarMenuActionPerformed

private void artistaListarMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_artistaListarMenuActionPerformed
// TODO add your handling code here:
    ArtistaListar artista;
        
            artista = new ArtistaListar();
            artista.setVisible(true);
        
    this.dispose();
}//GEN-LAST:event_artistaListarMenuActionPerformed

private void albumCadastrarMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_albumCadastrarMenuActionPerformed
// TODO add your handling code here:
    CdCadastro cd = new CdCadastro();
    cd.setVisible(true);
    this.dispose();
}//GEN-LAST:event_albumCadastrarMenuActionPerformed

private void albumListarMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_albumListarMenuActionPerformed
// TODO add your handling code here:
    CdListar cd = new CdListar();
    cd.setVisible(true);
    this.dispose();
}//GEN-LAST:event_albumListarMenuActionPerformed

private void musicaCadastrarMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_musicaCadastrarMenuActionPerformed
// TODO add your handling code here:
    MusicaCadastro musica;
        try {
            musica = new MusicaCadastro();
            musica.setVisible(true);
            this.dispose();
        } catch (BDException ex) {
            Logger.getLogger(PaginaInicial.class.getName()).log(Level.SEVERE, null, ex);
        }
    
}//GEN-LAST:event_musicaCadastrarMenuActionPerformed

private void musicaListarMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_musicaListarMenuActionPerformed
// TODO add your handling code here:
    MusicaListar musica = new MusicaListar();
    musica.setVisible(true);
    this.dispose();
}//GEN-LAST:event_musicaListarMenuActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ArtistaCadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ArtistaCadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ArtistaCadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ArtistaCadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ArtistaCadastro().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem albumCadastrarMenu;
    private javax.swing.JMenuItem albumListarMenu;
    private javax.swing.JMenu albumMenu;
    private javax.swing.JMenuItem artistaCadastrarMenu;
    private javax.swing.JTextArea artistaDescricaoField;
    private javax.swing.JMenuItem artistaListarMenu;
    private javax.swing.JMenu artistaMenu;
    private javax.swing.JTextField artistaNomeField;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JMenuItem musicaCadastrarMenu;
    private javax.swing.JMenuItem musicaListarMenu;
    private javax.swing.JMenu musicaMenu;
    // End of variables declaration//GEN-END:variables
}
